package com.learn.service.second.api.impl;

import java.util.*;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.learn.service.second.api.ErEmpMapper;
import com.learn.service.second.api.base.BaseApiService;
import com.learn.service.second.api.base.BaseResponse;
import com.learn.service.second.pojo.ErEmpEntity;
import com.learn.service.second.utils.PageUtils;
import com.learn.service.second.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * 
 *
 * @author sjf
 * @email 2334593702@qq.com
 * @date 2020-08-14 17:47:02
 */
@RestController
@RequestMapping("api/eremp")
@CrossOrigin
@Api("员工信息接口")
public class ErEmpController extends BaseApiService<JSONObject> {

    @Resource
    private ErEmpMapper erEmpMapper;

    @GetMapping("/allEmp")
    @ApiOperation(value = "员工信息接口", notes = "员工信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "e_name", value = "姓名", required = true,
            dataType = "String")})
    public BaseResponse<JSONObject> allEmp(ErEmpEntity erEmpEntity){

        HashMap<Object, Object> empHashMap = new HashMap<Object, Object>();
//        QueryWrapper<ErEmpEntity> queryWrapper = new QueryWrapper<ErEmpEntity>();
//        queryWrapper.eq(StringUtils.isNoneEmpty(erEmpEntity.getEName()),"e_name",erEmpEntity.getEName());

        List<ErEmpEntity> empEntityList= erEmpMapper.getlist();

        empHashMap.put("list",empEntityList);

//        ArrayList<ErEmpEntity> empEntityArrayList new A

//        ArrayList<Object> objects = new ArrayList<Object>();

//        for (ErEmpEntity er:empEntityList) {
//            System.out.println(er.getEName()+"名称");
//        }
//
//        System.out.println(empEntityList.size()+"数量");
//        for (ErEmpEntity e:empEntityList) {
//            empHashMap.put("e_name",e.getEName());
//            empHashMap.put("e_number",e.getENumber());
//        }

        return setResultSuccess((JSONObject) JSONObject.toJSON(empHashMap));
    }

   /* *//**
     * 列表
     *//*
    @RequestMapping("/list")
  //  @RequiresPermissions("api:eremp:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = erEmpMapper.queryPage(params);

        return R.ok().put("page", page);
    }


    *//**
     * 信息
     *//*
    @RequestMapping("/info/{eId}")
   // @RequiresPermissions("api:eremp:info")
    public R info(@PathVariable("eId") Integer eId){
		ErEmpEntity erEmp = erEmpMapper.selectById(eId);

        return R.ok().put("erEmp", erEmp);
    }

    *//**
     * 保存
     *//*
    @RequestMapping("/save")
   // @RequiresPermissions("api:eremp:save")
    public R save(@RequestBody ErEmpEntity erEmp){
		erEmpMapper.insert(erEmp);

        return R.ok();
    }

    *//**
     * 修改
     *//*
    @RequestMapping("/update")
    //@RequiresPermissions("api:eremp:update")
    public R update(@RequestBody ErEmpEntity erEmp){
		erEmpMapper.updateById(erEmp);

        return R.ok();
    }*/

    /**
     * 删除
     */
//    @RequestMapping("/delete")
//    //@RequiresPermissions("api:eremp:delete")
//    public R delete(@RequestBody Integer[] eIds){
//		erEmpMapper.removeByIds(Arrays.asList(eIds));
//
//        return R.ok();
//    }

}
